local jlwb = fk.CreateSkill({
  name = "df__jinglingwubu",
})


Fk:loadTranslationTable {
["df__jinglingwubu"] = "精灵舞步",
[":df__jinglingwubu"] = "每回合限一次，当你需要使用牌时，你可以重铸三张牌，或将手牌数调整至3。",
["#df__jinglingwubu"] = "",
["$df__jinglingwubu1"] = "",
["$df__jinglingwubu2"] = "",
}

jlwb:addEffect(fk.PreCardEffect, {
  anim_type = "negative",
  prompt = "重铸三张牌，或将手牌数调整至3",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(jlwb.name) and player == data.to and data.from and data.card
    and player:usedSkillTimes(jlwb.name, Player.HistoryTurn) == 0
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local choice = room:askToChoice(player, {
        choices = {"重铸三张牌" , "将手牌数调整至3"},
        skill_name = jlwb.name
    })
    if choice == "将手牌数调整至3" then
        local n = player:getHandcardNum()-3
        if n > 0 then
            room:askToDiscard(player, {
            min_num = n,
            max_num = n,
            include_equip = false,
            skill_name = jlwb.name,
            cancelable = false
            })
        else
            player:drawCards(-n, jlwb.name)
        end
    else
        local cards= room:askToChooseCards(player, {
        target = player,
        min = 3,
        max = 3,
        flag = "he",
        skill_name = jlwb.name
        })
        room:recastCard(cards, player, jlwb.name)
    end
  end,
})

jlwb:addEffect("active", {
  anim_type = "offensive",
  card_num = 0,
  target_num = 0,
  can_use = function(self, player)
    return player:usedSkillTimes(jlwb.name, Player.HistoryTurn) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = effect.from
    local room = player.room
    local choice = room:askToChoice(player, {
        choices = {"重铸三张牌" , "将手牌数调整至3"},
        skill_name = jlwb.name
    })
    if choice == "将手牌数调整至3" then
        local n = player:getHandcardNum()-3
        if n > 0 then
            room:askToDiscard(player, {
            min_num = n,
            max_num = n,
            include_equip = false,
            skill_name = jlwb.name,
            cancelable = false
            })
        else
            player:drawCards(-n, jlwb.name)
        end
    else
        local cards= room:askToChooseCards(player, {
        target = player,
        min = 3,
        max = 3,
        flag = "he",
        skill_name = jlwb.name
        })
        room:recastCard(cards, player, jlwb.name)
    end
  end,
})

return jlwb 